import numpy as np
import matplotlib

matplotlib.use(backend="TkAgg")
import matplotlib.pyplot as plt
import pandas as pd
from math import isclose
import random
from collections import Counter
import numpy.random as npr
import numpy.linalg as linalg

np.set_printoptions(precision=4, suppress=True)

print("Section2: Reducible chain example (two disjoint components)")

P2 = np.array([
    [0.5, 0.5, 0.0, 0.0], # 状态0: 只能在{0,1}之间转移
    [0.5, 0.5, 0.0, 0.0], # 状态1: 只能在{0,1}之间转移
    [0.0, 0.0, 0.2, 0.8], # 状态2: 只能在{2,3}之间转移
    [0.0, 0.0, 0.9, 0.1] # 状态3: 只能在{2,3}之间转移
])

print(pd.DataFrame(P2))

print("This P2 splits into {0,1} and {2,3} communicating classes."
      " Start in class {0,1} you never reach {2,3}")